home *** CD-ROM | disk | FTP | other *** search
- /* MainWindow.c */
- /* Created 6/10/97 12:23 PM by AppMaker */
-
- #include <Types.h>
- #include <Quickdraw.h>
- #include <Controls.h>
- #include <Dialogs.h>
- #include <Events.h>
- #include <Lists.h>
- #include <Menus.h>
- #include <Resources.h>
- #include <TextEdit.h>
- #include <ToolUtils.h>
- #include "ResourceDefs.h"
- #include "Globals.h"
- #include "Miscellany.h"
- #include "Scrolling.h"
- #include "WindowAids.h"
- #include "AMReminderData.h"
- #include "Add.h"
- #include "MainWindow.h"
-
-
- #define LogoPicture 1
- #define YearLabel 2
- #define RemindersLabelLabel 3
- #define RemindersList 4
- #define AddButton 5
- #define Add2Button 6
- #define DeleteButton 7
-
- static void BuildRemindersList (void);
- static void DoAddButton (void);
- static void DoAdd2Button (void);
- static void DoDeleteButton (void);
-
- /*----------*/
- static void BuildRemindersList ()
- {
- Rect bounds;
-
- SetWFont (RemindersList);
- GetWRect (RemindersList, &bounds);
- cur->RemindersHandle = NewV1List (bounds, qd.thePort);
- AddToList ("\pOne", cur->RemindersHandle);
- AddToList ("\pTwo", cur->RemindersHandle);
- AddToList ("\pThree", cur->RemindersHandle);
- AddToList ("\pInfinity", cur->RemindersHandle);
- LSetDrawingMode (true, cur->RemindersHandle);
-
- } /*BuildRemindersList*/
-
- /*----------*/
- static void DoAddButton ()
- {
- AddRec AddInfo;
- register AddRecPtr info;
-
- info = &AddInfo;
- /*initialize Add info*/
- info->LogoData = nil;
- info->Date2Text [0] = 0;
- info->Time2Text [0] = 0;
- info->AmPmChoice = 1;
- info->Message2Text [0] = 0;
- info->DisplayIconChecked = false;
- info->DisplayAlertChecked = false;
- info->PlaySoundChecked = false;
- info->SoundChoice = 1;
-
- if (GetAdd (&AddInfo)) {
- /*use Add info*/
- }
- } /*DoAddButton*/
-
- /*----------*/
- static void DoAdd2Button ()
- {
- AddRec AddInfo;
- register AddRecPtr info;
-
- info = &AddInfo;
- /*initialize Add info*/
- info->LogoData = nil;
- info->Date2Text [0] = 0;
- info->Time2Text [0] = 0;
- info->AmPmChoice = 1;
- info->Message2Text [0] = 0;
- info->DisplayIconChecked = false;
- info->DisplayAlertChecked = false;
- info->PlaySoundChecked = false;
- info->SoundChoice = 1;
-
- if (GetAdd (&AddInfo)) {
- /*use Add info*/
- }
- } /*DoAdd2Button*/
-
- /*----------*/
- static void DoDeleteButton ()
- {
- } /*DoDeleteButton*/
-
- /*----------*/
- void OpenMainWindow (FSSpec* fileSpec,
- short fRefNum)
- {
- WindowPtr newWindow;
- Rect bounds;
-
- newWindow = GetWindow (WIND_MainWindow);
- if (fileSpec->name [0] != 0) {
- SetWTitle (newWindow, fileSpec->name);
- }
- SetPort (newWindow);
- SetNewInfo (newWindow);
- cur->vScroll = nil;
- cur->hScroll = nil;
- cur->fileNum = fRefNum;
- cur->dirty = false;
- cur->filename = NewString (fileSpec->name);
- cur->windowKind = WMainWindow;
- ((WindowPeek) curWindow)->windowKind = userKind + WMainWindow;
- cur->witlHandle = GetResource ('Witl', WIND_MainWindow);
- cur->wictHandle = GetResource ('Wict', WIND_MainWindow);
-
- BuildRemindersList ();
- cur->AddHandle = GetNewControl (CNTL_Add, newWindow);
- cur->Add2Handle = GetNewControl (CNTL_Add2, newWindow);
- cur->DeleteHandle = GetNewControl (CNTL_Delete, newWindow);
-
- cur->text = nil;
- ShowWindow (newWindow);
- } /*OpenMainWindow*/
-
- /*----------*/
- void CloseMainWindow (void)
- {
- LDispose (cur->RemindersHandle);
-
- DisposeHandle ((Handle) cur->filename);
- DiscardInfo (curWindow);
- } /*CloseMainWindow*/
-
- /*----------*/
- void ControlMainWindow (ControlHandle whichControl,
- short whichPart,
- Point where)
- {
- Rect bounds;
-
- if ((whichControl == (**(cur->RemindersHandle)).vScroll)
- || (whichControl == (**(cur->RemindersHandle)).hScroll)) {
- if (LClick (where, 0, cur->RemindersHandle)) {
- /*double click in scroll bar*/
- }
- }
- if (whichControl == cur->AddHandle) {
- if (TrackButton (cur->AddHandle, where)) {
- DoAddButton ();
- }
- }
- if (whichControl == cur->Add2Handle) {
- if (TrackButton (cur->Add2Handle, where)) {
- DoAdd2Button ();
- }
- }
- if (whichControl == cur->DeleteHandle) {
- if (TrackButton (cur->DeleteHandle, where)) {
- DoDeleteButton ();
- }
- }
-
- } /*ControlMainWindow*/
-
- /*----------*/
- void MouseInMainWindow (Point where,
- short modifiers)
- {
- Rect bounds;
-
- if (PtInRect (where, &(**(cur->RemindersHandle)).rView)) {
- if (LClick (where, modifiers, cur->RemindersHandle)) {
- /*double click*/
- }
- if (GetListChoice (&cur->RemindersChoice, cur->RemindersHandle)) {
- /* something is selected */
- }
- }
-
- } /*MouseInMainWindow*/
-
- /*----------*/
- void TypeInMainWindow (char ch)
- {
- if ((ch == charEnter)
- || (ch == charReturn)) {
- SimulateClick (cur->AddHandle);
- DoAddButton ();
- } else if (ch == charEsc) {
- } else if (ch == charTab) {
- /* tab among edit fields */
- } else if (cur->text == nil) {
- SysBeep (1);
- } else {
- TEKey (ch, cur->text);
- cur->dirty = true;
- }
- } /*TypeInMainWindow*/
-
- /*----------*/
- void UpdateMainWindow (void)
- {
- Rect bounds;
-
- GetWRect (LogoPicture, &bounds);
- DrawPictureID (PICT_Logo, bounds);
-
- SetWFont (YearLabel);
- GetWRect (YearLabel, &bounds);
- TextIDBox (TEXT_Year, bounds);
-
- SetWFont (RemindersLabelLabel);
- GetWRect (RemindersLabelLabel, &bounds);
- TextIDBox (TEXT_RemindersLabel, bounds);
-
- SetWFont (RemindersList);
- LUpdate (qd.thePort->visRgn, cur->RemindersHandle);
- bounds = (**(cur->RemindersHandle)).rView;
- InsetRect (&bounds, -1, -1);
- FrameRect (&bounds);
- SetWFont (AddButton);
- Draw1Control (cur->AddHandle);
- OutlineButtonRect ((**(cur->AddHandle)).contrlRect);
- SetWFont (Add2Button);
- Draw1Control (cur->Add2Handle);
- SetWFont (DeleteButton);
- Draw1Control (cur->DeleteHandle);
- } /*UpdateMainWindow*/
-
- /*----------*/
- void ActivateMainWindow (Boolean activate)
- {
- LActivate (activate, cur->RemindersHandle);
-
- } /*ActivateMainWindow*/
-
- /*----------*/
- void ResizeMainWindow (void)
- {
- /* application-specific code to resize items in window */
- } /*ResizeMainWindow*/
-
- /*----------*/
- pascal void ScrollMainWindow (short newValue,
- short oldValue)
- {
- /* application-specific code to scroll window */
- if (gWhichScroll == cur->vScroll) {
- } else { // horizontal
- }
- } /*ScrollMainWindow*/
-
- /* MainWindow */
-